﻿using System;
using System.IO;

namespace FileMergeConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {  
            Console.WriteLine("请输入第一个文件的完整路径:");
            string filePath1 = Console.ReadLine();
            Console.WriteLine("请输入第二个文件的完整路径:");
            string filePath2 = Console.ReadLine();
            if (!File.Exists(filePath1) || !File.Exists(filePath2))
            {
                Console.WriteLine("一个或多个文件不存在，请检查路径。");
                return;
            }
            try
            {
                string content1 = File.ReadAllText(filePath1);
                string content2 = File.ReadAllText(filePath2);
                string directoryPath = Path.Combine(Directory.GetCurrentDirectory(), "Data");
                if (!Directory.Exists(directoryPath))
                {
                    Directory.CreateDirectory(directoryPath);
                }
                string mergedContent = content1 + Environment.NewLine + content2;

                string newFilePath = Path.Combine(directoryPath, "mergedFile.txt");
                File.WriteAllText(newFilePath, mergedContent);
                Console.WriteLine($"文件合并成功！新文件保存于：{newFilePath}");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"发生错误：{ex.Message}");
            }
        }
    }
}